<?php

/** 
 * @author Nguyen
 * 
 */
class ModelFactory {
	
	private $_context;
	/**
	 */
	function __construct() {
		
	}
	/**
	 * Get Model Instance By name.
	 * @param String $modelName
	 * @throws ModelFactoryException
	 * @return BaseModel.
	 */
	public static function instance($modelName){
		$path = Config::MODEL_FOLDER . Config::SLASH . $modelName . '.php';
		if(file_exists($path)){
			include_once $path;
			if(class_exists($modelName)){
				return new $modelName;	
			}
			else{
				throw new ModelFactoryException('Class '.$modelName.' not found!');
				return null;
			}
		}
		else{
			throw new ModelFactoryException('Model file not found!');
			return null;
		}
	}
}

?>